﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yule8xCommon.Applib;
using Yule8xCommon.Typelib;
using Yule8xModel;
using Yule8xModel.PageModels;

namespace Yule8xWechat.Test
{
    public partial class AgentIndex : System.Web.UI.Page
    {
        protected AgentIndexPageModels.AgentIndexPageData pageData;
        protected WxUserInfoResult wxUser;
        protected void Page_Load(object sender, EventArgs e)
        {
            int user_id = RequestUtil.GetInteger("user_id");
            if (user_id < 1)
            {
                Response.Write("请输入user_id参数");
                Response.End();
            }
            wxUser = UserModels.GetWxUserInfo(user_id);
            if (null == wxUser)
            {
                Response.Write("未登录");
                Response.End();
            }
            bool isAgent = UserModels.CheckUserIsAgent(wxUser.user_id);
            if (!isAgent)
            {
                Response.Write("不是代理，无权查看");
                Response.End();
            }
            pageData = AgentIndexPageModels.GetPageData(wxUser.user_id);
            if (null == pageData)
            {
                Response.Write("[代理首页] 未发现用户记录, 可能系统正在维护");
                Response.End();
            }

        }
    }
}